GBML manual / Maps

map_clear

Removes every key/value pair from target, leaving it empty (map_length(target) becomes 0). target's own declared capacity is unchanged - it can be filled again afterward.

Syntax

map_clear(target)

Arguments

NameType
targetmap

Returns

Nothing.

Description

Removes every key/value pair from target, leaving it empty (map_length(target) becomes 0). target's own declared capacity is unchanged - it can be filled again afterward.

Example

/// @type {map<string,int>}
var scores = {};
map_set(scores, "alice", 10);
map_clear(scores);
var count = map_length(scores); // 0
A real capture - the map and its length before clearing, 1 entryA real capture - the map and its length before clearing, 1 entry
A real capture - the map and its length before clearing, 1 entry
The same map after map_clear(scores) - empty, and map_length back to 0The same map after map_clear(scores) - empty, and map_length back to 0
The same map after mapclear(scores) - empty, and maplength back to 0

On the GBA

The hash map's clear() - O(n) in how many pairs target held (each one's destructor runs).

See also: map_setmap_getmap_lengthmap_hasData containers